<template>
	<view class="page__content">

		<view class="page__content__main">

			<up-empty mode="history" :icon="uni.$utils.getResourceUrl('assets/image/img/history.png')" iconSize="160"
				text="请手动配对设备">
				<!-- <template> -->
					<button type="primary" class="content_bottom_primary_Btn" @click="openBluetoothSetting">
						<text>点击前往配对</text>
					</button>
				<!-- </template> -->
			</up-empty>
		</view>
	</view>
</template>

<script setup lang="ts" name="page-link-hid">
	import { useMainStore } from '@/store';
	const mainStore = useMainStore();
	let sysDeviceInfo = mainStore.systemConfig.sysDeviceInfo;
	console.log(sysDeviceInfo);

	const openBluetoothSetting = () => {
		switch (sysDeviceInfo.platform) {
			case "android":
				try {
					let main = plus.android.runtimeMainActivity();
					let Intent = plus.android.importClass('android.content.Intent');
					let Settings = plus.android.importClass('android.provider.Settings');
					let intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
					main.startActivity(intent);
				} catch (e) {
					console.error('跳转失败', e);
					uni.showToast({
						title: '无法打开蓝牙设置',
						icon: 'none'
					});
				}
				break;
			case "ios":
				plus.runtime.openURL('App-Prefs:root=Bluetooth');
				break;
			default:
				uni.$utils.msg("当前平台不支持跳转")
				break;
		}
	}
</script>

<style lang="scss">
	.page__content {
		height: 100%;

		&__main {
			.content_bottom_primary_Btn {
				font-size: 14px;
				margin-top: 15px;
				padding: 4px 15px;
			}
		}
	}
</style>